import server from "../utils/request";

export const getHome = () => {
  return server({
    url: "/api/wx/home/index",
  });
};

export const getClassify = () => {
  return server({
    url: "/api/wx/catalog/index",
  });
};

export const getCurrentClassify = (id) => {
  return server({
    url: `/api/wx/catalog/current?id=${id}`,
  });
};

export const postLogin = (data) => {
  return server({
    url: "/api/wx/auth/login",
    method: "post",
    data,
  });
};

export const getCart = () => {
  return server({
    url: "/api/wx/cart/index",
  });
};

export const getMine = () => {
  return server({
    url: "/api/wx/user/index",
  });
};

export const getDetail = (id) => {
  return server({
    url: `/api/wx/goods/detail?id=${id}`,
  });
};

export const getInfo = () => {
  return server({
    url: "/api/wx/auth/info",
  });
};

export const postDelate = (data) => {
  return server({
    url: "/api/wx/cart/delete",
    data,
    method: "post",
  });
};

export const postAddCart = (data) => {
  return server({
    url: "/api/wx/cart/add",
    data,
    method: "post",
  });
};

export const postLogOut = () => {
  return server({
    url: "/api/wx/auth/logout",
    method: "post",
  });
};

export const postUpdate = (data) => {
  return server({
    url: "/api/wx/cart/update",
    data,
    method: "post",
  });
};

export const getSettle = (cartId=0,addressId=0) => {
  return server({
    url: `/api/wx/cart/checkout?cartId=${cartId}&addressId=${addressId}&couponId=0&userCouponId=0&grouponRulesId=0`,
  })
}
